/**
 * 
 */
package com.suyx.job.utils.mh;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.suyx.job.utils.ScreenCapture;

import lombok.extern.slf4j.Slf4j;

/**
 * @author syx
 *
 */
@Slf4j
@Component
public class WzgScene {

	@Autowired
	private WaTuUtils waTuUtils;
	
	public final static Map<String,String> options_x = new HashMap<>();  
	public final static Map<String,String> options_y = new HashMap<>();
	static {  
		options_x.put("0", "711 329");  
		options_x.put("1", "400 225");  
		options_x.put("2", "500 225");
		options_x.put("3", "600 225"); 
		options_x.put("4", "400 325");
		options_x.put("5", "500 325");
		options_x.put("6", "600 325");
		options_x.put("7", "400 425");
		options_x.put("8", "500 425");
		options_x.put("9", "600 425");
		
		options_y.put("0", "837 320");  
		options_y.put("1", "550 226");  
		options_y.put("2", "650 226");
		options_y.put("3", "750 226"); 
		options_y.put("4", "550 326");
		options_y.put("5", "650 326");
		options_y.put("6", "750 326");
		options_y.put("7", "550 426");
		options_y.put("8", "650 426");
		options_y.put("9", "750 426");
	} 
	
	public  void wzg(String device ,String zuobiao,String baoguo) throws Exception{
		//打开包裹
		ScreenCapture.mouseClick(device, "1308 675");
		ScreenCapture.mouseClick(device, "730 224");// 打开ca7
		ScreenCapture.mouseClick(device, "522 422");// 使用
		ScreenCapture.mouseClick(device, "277 600");//7到CA到GJ 
		ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
		ScreenCapture.mouseClick(device, "99 652");// 
		
		//先到达大唐国境
		Thread.sleep(2 * 1000L);
		ScreenCapture.mouseClick(device, "117 68");//打开地图
		ScreenCapture.mouseClick(device, "504 533");// 
		ScreenCapture.mouseClick(device, "1117 48"); //关闭地图
		Thread.sleep(70 * 1000L);
		ScreenCapture.mouseClick(device, "400 495");
		ScreenCapture.mouseClick(device, "21 623"); //传送到大唐境外
		Thread.sleep(3 * 1000L);
		ScreenCapture.mouseClick(device, "410 689");
		ScreenCapture.mouseClick(device, "117 68");//打开地图
		ScreenCapture.mouseClick(device, "1236 329");
		ScreenCapture.mouseClick(device, "1256 200"); //关闭地图
		Thread.sleep(36 * 1000L);
		ScreenCapture.mouseClick(device, "1413 127");
		
	}
	
	public  void wzgSceneSame(String device,String zuobiao,String baoguo) throws Exception{
		Thread.sleep(2 * 1000L);
		ScreenCapture.mouseClick(device, "117 68");//打开地图
        ScreenCapture.mouseClick(device, "418 114");// 选x坐标
        String x = zuobiao.split(" ")[0];
        String y = zuobiao.split(" ")[1];
        input_x(device,x);
        ScreenCapture.mouseClick(device, "700 425");
        ScreenCapture.mouseClick(device, "553 107"); // 选y坐标
        input_y(device, y);
        ScreenCapture.mouseClick(device, "850 426");
        ScreenCapture.mouseClick(device, "690 109");  // 前往
        ScreenCapture.mouseClick(device, "1138 78"); //关闭地图
        //开始挖图
        waTuUtils.startWatu(device, zuobiao, baoguo);
	}
	
	public  void input_x(String device,String x){
		for(int i =0;i<x.length();i++){
			char c = x.charAt(i);
			String x_zb = options_x.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, x_zb);
		}
	}
	
	public  void input_y(String device,String y){
		for(int i =0;i<y.length();i++){
			char c = y.charAt(i);
			String y_zb = options_y.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, y_zb);
		}
	}
}
